const SESSION_KEY = 'session'

export default {
  set (key, value) {
    sessionStorage.setItem(key, (value instanceof Object) ? JSON.stringify(value) : value)
  },
  get (key) {
    let value = sessionStorage.getItem(key)

    try{
      value = JSON.parse(value)
    }catch (e) {
      value = value ? value : undefined
    }
    return value
  },
  remove(key){
    sessionStorage.removeItem(key)
  },
  clear(){
    sessionStorage.clear()
  }
}
